import React from "react";
import { Input } from "antd";
import classnames from "classnames";
import { SearchOutlined } from "@/config/antdIcon";
import "./index.scss";

export default function FormInput(props) {
  const {
    admLabel = "",
    labelPosition = "top",
    onChange = () => { },
    placeholder = "请输入",
    value = "",
    disabled = false,
    className = "",
    onPressEnter = () => { },
    onBlur = () => { },
    isShowAfterIcon = false,
    isRequired = false,  // 标题前的*
  } = props;

  return (
    <div
      className={classnames({
        "zz-form-input": true,
        "form-input-top": labelPosition == "top",
        "form-input-left": labelPosition == "left",
        [className]: className != "",
      })}
    >
      {admLabel && (
        <div className="zz-form-name">
          {isRequired ? <label className="required">*</label> : null}
          <label>{admLabel}</label>
        </div>
      )}
      <div className="zz-form-content">
        <Input
          placeholder={placeholder}
          value={value || ""}
          onChange={onChange}
          disabled={disabled}
          onBlur={onBlur}
          onPressEnter={onPressEnter}
        />
        {isShowAfterIcon ? <SearchOutlined
          className="search-icon"
        /> : null}
      </div>
    </div>
  );
}
